package day03;

public class OperDemo {
    public static void main(String[] args) {
        /*
        //若为true则为？号后面的数1，若为false则为:号后的数2
        int num = 5;
        int a = 5,b = 6;
        int flag = num >0?1:-1;
        System.out.println(flag);//若num=5，则为1，若num=-5，则为-1

        int max = a>b?a:b;
        System.out.println(max);//

        字符串连接
        System.out.println(10+20+""+30);//3030----Steing
        System.out.println(""+10+20+30);//102030
        System.out.println(10+20+30+"");//60
        System.out.println(10+20+""+(int)(10+20)+30);//303030

        int age = 28;
        String name = "小明";
        String b = "江西南昌";
        String c = "我家是";
        String d = "大家好,我叫";
        String j = ",今年";
        String l = "岁了。";
        System.out.println("age=");//age=
        System.out.println(age);//28
        System.out.println("age"+age);//age=28
        System.out.println("我今年"+age+"岁了");//我今年28岁了
        System.out.println("大家好，我叫"+name);//大家好，我叫小明
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了");//大家好，我叫小明，今年28岁了
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了。"+c+b);//大家好，我叫小明，今年28岁了。我家是江西南昌
        System.out.println(d+name+j+age+l+c+b);//大家好,我叫小明,今年28岁了。我家是江西南昌

        //+=  -=  /=  *=  %=,都是强行转换
        int a = 5,b = 6,c = 8;
        a+=10;//相当于a=(int)(a+10)
        System.out.println(a);//15
        a*=6;
        System.out.println(a);//90
        a/=2;
        System.out.println(a);//45
        short a1 = 5,b1 = 6,c1 = 8;
        //a1 = a1 + 10;编译错误,强转:a1=(short)(a1+10)
        a1 += 10;//相当于a1=(short)(a1+10)
        System.out.println(a1);//15

        int number = 1001;
        String numberStr = "学号:";
        int b = 28;
        String age = "年龄:";

        String info = numberStr + number;//学号:1001
        String info3 = age + b;//年龄:28
        boolean b1 = true;
        String info1 = info+info3;
        System.out.println(info1);//学号:1001 年龄:28

        //判断  &&短路与（并且），见false则false，都要对
           ||短路或（或者），见真则真，对一个即可
           !逻辑非（取反），对就是错，错就是对
        int a = 10,b = 20,c = 12,d = 10;
        boolean b3 = a>b && c++>2;
        System.out.println(b3);//false
        System.out.println(c);//12,短路了
        boolean b4 = a>b || c++ <a;
        System.out.println(b4);//false
        System.out.println(c);//13，短路了

        boolean b2 = !(a<b);
        int age = 38;
        int score = 66;
        System.out.println(!(c>a));//false
        System.out.println(!(a==d) || !(a!=d));//true
        System.out.println(b2);//false
        System.out.println(score<0 || score>100);//成绩不合格验证，false

        int a = 10,b = 20,c = 12,d = 10;
        boolean b1 = b>=a && d==a;
        System.out.println(b1);//true
        System.out.println(b<=a && b>a);//false
        System.out.println(a==d && b>=a+c);//false
        System.out.println(c+d>b && b-d==a);//true

        System.out.println(b!=a+d || d==a);//true
        System.out.println(b==c+8 || d+a>b);//true
        System.out.println(b>c+d || c%3==d%3);//false

        int age = 28;
        int score = 66;
        System.out.println(age>=18 && age<=50);//18到50之间，true
        System.out.println(score>=0 && score<=100);//0到100之间 true

        //boolean为判断，对 true ,错 false
        int a = 10,b = 20,c = 12,d = 10;
        boolean  b1 = b<=a+d;
        System.out.println(b1);//true
        System.out.println(a<d);//false
        System.out.println(c>d);//true
        System.out.println(a+d==b);//true
        System.out.println(b-a!=d);//false
        System.out.println(c%2==0);//true
        System.out.println(a++>d);//false
        System.out.println(a++>d);//true
        System.out.println(a++==c);//true

        int a = 5,b = 6, c = 7,d = 8;
        int t = a++;
        int q = --b;
        int l = a + c - q;
        int i = l + d%3;
        System.out.println(a);//6
        System.out.println(b);//5
        System.out.println(t);//5
        System.out.println(q);//5
        System.out.println(l);//8
        System.out.println(i);//10

        int a = 5,b = 5;
        int c = a--;//将a--的值5赋值给c，同时a自减一
        int d = --b;//将--b的值4赋值给c，同时b自减一
        System.out.println(a);//4
        System.out.println(b);//4
        System.out.println(c);//5
        System.out.println(d);//4

        //单独使用，a++的值为a+1，++a的值为a+1
        //被使用，a++的值为a，++a的值为a+1
        int a1 = 5,b1 = 5;
        a1++;
        ++b1;
        System.out.println(a1);//6
        System.out.println(b1);//6

        int a = 10,b = 10;
        int c = a++;//将a++的值5赋值给c，同时a自增加一
        int d = ++b;//将++b的值6赋值给d，同时d自增加一
        System.out.println(a);//11
        System.out.println(b);//11
        System.out.println(c);//10
        System.out.println(d);//11
        //%取模/取余
        System.out.println(6%2);//0 商3余0
        System.out.println(9%2);//1 商4余1
        System.out.println(3%6);//3 商0余3
         */

    }
}
